import React, { Component } from 'react';
import { Route, Switch, Redirect } from 'react-router-dom'
import CeshiContainer from './StyledCeshi'
import Renwu from './child/Renwu'
import Pingjia from './child/Pingjia'

import Fanhui from 'images/nav/whiteback.png'


// 头部引入
import Navigation from 'components/Navigation/Navigation'
//TitleBar引入
import TitleBar from 'pages/hall/component/Titlebar'

const barArr = [
    {
    title : "任务",
    routePath : "/ceshi/renwu",
    component : Renwu,
    tag : 0,
  },
  {
    title : "评价",
    routePath : "/ceshi/pingjia",
    component : Pingjia,
    tag : 1,
  },]
  let selBill = 0


class Ceshi extends Component {
	state = {}
	render() {
        barArr.forEach((value,index)=>{
            console.log(value,index);
            
            if(value.routePath === this.props.location.pathname){
              selBill  = value.tag
            }
          })

		// barArr.forEach((value,index)=>{
		// 	console.log(value,index);

		// 	if(value.routePath === this.props.location.pathname){
		// 	  selBill  = value.tag
		// 	}
		//   })

		return (
			<CeshiContainer>
				<Navigation
                    title = "测试"
					backgroundColor='#56D9D1'
					leftImg={Fanhui}
					leftImgWidth='.2rem'
					leftImgHeight='.2rem'
					leftPadding='0 0 0 .095rem'
					clickLeft={() => this.onClickLeft("left")}
				>
				</Navigation>

                <div className="personal">123</div>

                <TitleBar
                    barArr = {barArr}
                    taskIndex = {selBill}
                    titleBorderWidth='0 0 5px 0'
                    titleWidth = '.61rem'
                    titleHeigh= '.48rem'
                    selectedTitleBorderColor='#56D9D1'
                    titleColor = '#646464'
                    titleSize = '.13rem'
                    ></TitleBar>

<Switch>
          {
            barArr.map((value,index)=>(
              <Route key={index} path={value.routePath} component={value.component}></Route>
            ))
          }
          <Redirect from="/bill" to={barArr[selBill?selBill:0].routePath} exact></Redirect>
          {/* <Route component={Page404}></Route> */}
        </Switch>

				

			



			</CeshiContainer>
		)
	}
}

export default Ceshi